package com.rin.config;

import com.rin.executor.AnnotationExecutor;
import com.rin.executor.FillIdRule;
import org.apache.hadoop.fs.FileSystem;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

/**
 * @author RinMi
 * @since 2023/6/13
 */

@Configuration
public class Config {

    @Bean
    public FileSystem getFileSystem() {
        FileSystem fileSystem = null;
        try {
            fileSystem = FileSystem.get(new URI("hdfs://" + HDFSConfig.HOSTNAME + ":" + HDFSConfig.PORT),
                    new org.apache.hadoop.conf.Configuration(), HDFSConfig.USERNAME);
        } catch (IOException | InterruptedException | URISyntaxException e) {
            e.printStackTrace();
        }
        return fileSystem;
    }

    @Bean
    public FillIdRule getFillIdRule() {
        return new FillIdRule();
    }

    @Bean
    public AnnotationExecutor getAnnotationExecutor() {
        return new AnnotationExecutor();
    }
}
